package com.baboba.rummy.player;

import java.util.LinkedList;
import java.util.List;

import com.baboba.rummy.card.UserCard;
import com.baboba.rummy.game.PlayerStateChangedCallback;

public abstract class Player {
	protected String id;
	protected String name;
	protected int score;
	protected List<Integer> scoreHistory;
	protected LinkedList<UserCard> cards;
	protected String logoImage;
	protected PlayerEventHandler playerHandler;
	protected boolean iceBreak;
	protected PlayerStateChangedCallback stateChangedCallback;
	
	public Player(String id, String displayName){
		this.id = id;
		this.name = displayName;
	}
	
	public void initFirstHandCards(LinkedList<UserCard> cards){
		this.cards = cards;
		for (UserCard card : cards)
			card.setUserID(id);
		
		if (playerHandler!=null)
			playerHandler.onInitFirstHandCards(cards);
	}
	
	public abstract List<UserCard> nextStep();
	
	public void addNewCard(UserCard card){
		card.setUserID(id);
		
		if (playerHandler!=null)
			playerHandler.onAddNewCard(card);
	}

	public int getScore() {
		return score;
	}

	public void setScore(int score) {
		this.score = score;
	}

	public String getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public String getLogoImage() {
		return logoImage;
	}

	public void setLogoImage(String logoImage) {
		this.logoImage = logoImage;
	}

	public void setPlayerHandler(PlayerEventHandler playerHandler) {
		this.playerHandler = playerHandler;
	}

	public void setStateChangedCallback(
			PlayerStateChangedCallback stateChangedCallback) {
		this.stateChangedCallback = stateChangedCallback;
	}
}
